//
//  bouceView.m
//  SmileWeather
//
//  Created by lanou3g on 15/9/17.
//  Copyright (c) 2015年 陶天海. All rights reserved.
//

#import "bouceView.h"
static CGRect tempFrame;
@implementation bouceView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _label = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, kWidth, 150)];
        [self addSubview:_label];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addData) name:@"relode" object:nil];
    self.oneView = [[UIView alloc] initWithFrame:CGRectMake(0, 140, kWidth, 125)];
    self.oneView.layer.cornerRadius = 3;
    self.oneView.backgroundColor = [UIColor colorWithWhite:0 alpha:.15];
    [self addSubview:self.oneView];
    self.towView = [[UIView alloc] initWithFrame:CGRectMake(0, 270,kWidth, 400)];
    self.userInteractionEnabled = YES;
    self.towView.userInteractionEnabled = YES;
    self.towView.layer.cornerRadius = 3;
    self.towView.backgroundColor = [UIColor colorWithWhite:0 alpha:.15];
    self.mood = [[molde alloc] init];
        
    [self addSubview:self.towView];
     self.ganmaoLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kWidth/3, kWidth/12.5)];
    self.ganmaoLab1 = [[MyScollview alloc] initWithFrame:CGRectMake(0, kWidth/12.5 + 2, kWidth, kWidth/12.5)str:@"fdkjakkajjkjajkajjkdjjfhdjajjajalfajjfkdsjhjhjhjhhjhjhkkkljkjklhjikjijijojohjhjhhklklhl"] ;
     self.kongtiaoLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 2*kWidth/12.5 +4,kWidth/3 , kWidth/12.5)];
     self.kongtiaoLab1 = [[MyScollview alloc] initWithFrame:CGRectMake(0, 3*kWidth/12.5 +6, kWidth, kWidth/12.5)str:@"转发大富科技阿克江房间爱健康进阿飞姐啊哈哈放空间啊"];
     self.chuanyiLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 4*kWidth/12.5 + 8, kWidth/3, kWidth/12.5)];
     self.chuanyiLab1 = [[MyScollview alloc] initWithFrame:CGRectMake(0, 5*kWidth/12.5 + 10, kWidth, kWidth/12.5)str:@"转发大富科技阿克江房间爱健康进阿飞姐啊哈哈放空间啊"];
     self.xicheLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 6*kWidth/12.5 +12, kWidth/3, kWidth/12.5)];
     self.xicheLab1 = [[MyScollview alloc]initWithFrame:CGRectMake(0, 7*kWidth/12.5 +14, kWidth, kWidth/12.5)str:@"转发大富科技阿克江房间爱健康进阿飞姐啊哈哈放空间啊"];
     self.wuranLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 8*kWidth/12.5 + 16, kWidth/3, kWidth/12.5)];
     self.wuranLab1 = [[MyScollview alloc] initWithFrame:CGRectMake(0, 9*kWidth/12.5 + 18, kWidth, kWidth/12.5)str:@"转发大富科技阿克江房间爱健康进阿飞姐啊哈哈放空间啊"];
     self.ziwaixianLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 10*kWidth/12.5 + 20, kWidth/3, kWidth/12.5)];
     self.ziwaixianLab1 = [[MyScollview alloc] initWithFrame:CGRectMake(0, 11*kWidth/12.5 +22, kWidth, kWidth/12.5)str:@"转发大富科技阿克江房间爱健康进阿飞姐啊哈哈放空间啊"];
     self.placeLable = [[UILabel alloc] initWithFrame:CGRectMake(kWidth-kWidth/2.2, 120-kWidth/12.5, kWidth/2.2, kWidth/12.5)];
   
      self.datimeLab = [[MyScollview alloc] initWithFrame:CGRectMake(2,64 , kWidth/2, kWidth/12.5)str:@"1234567897894561212还多久发货的"] ;
        self.datimeLab.title.textAlignment = NSTextAlignmentCenter;
        self.datimeLab.title.textColor = [UIColor whiteColor];
        self.datimeLab.title.numberOfLines = 0;
        self.pmLab = [[UILabel alloc] initWithFrame:CGRectMake(kWidth-kWidth/2.2,90-kWidth/12.5 , kWidth/2.2, kWidth/12.5)];
        self.qualityLab = [[UILabel alloc] initWithFrame:CGRectMake(kWidth-kWidth/2.2,60-kWidth/12.5 , kWidth/2.2, kWidth/12.5)];

    }
    return self;
}
-(void)addData{
    
      molde *mod= [[weatherHandle shareWetherHandle]arr][0];

    NSString *temperature = mod.info[@"day"][2];
    NSString *str = [NSString stringWithFormat:@"%@℃",temperature];

    _label.text = str;
    [_label setTextColor:[UIColor whiteColor]];
     
    [_label setFont:[UIFont fontWithName:@"HelveticaNeue-UltraLight" size:80]];
    [_label setShadowColor:[UIColor blackColor]];
    [_label setShadowOffset:CGSizeMake(2, 2)];

  self.ganmaoLab.text = [weatherHandle shareWetherHandle].mod.ganmao[0];
    self.ganmaoLab.text = [NSString stringWithFormat:@"%@ : %@",@"感冒",self.ganmaoLab.text];
      [self setMyLab:self.ganmaoLab];

    self.ganmaoLab1.title.text = [weatherHandle shareWetherHandle].mod.ganmao[1];
    //[self.towView addSubview:self.ganmaoLab1];
    
    [self setUpLable:self.ganmaoLab1];
    //[self setMyLab:self.ganmaoLab1.title];

    self.kongtiaoLab.text = [weatherHandle shareWetherHandle].mod.kongtiao[0];
    self.kongtiaoLab.text = [NSString stringWithFormat:@"%@ : %@",@"空调",self.kongtiaoLab.text];
    [self setMyLab:self.kongtiaoLab];

    self.kongtiaoLab1.title.text = [weatherHandle shareWetherHandle].mod.kongtiao[1];
    [self setUpLable:self.kongtiaoLab1];

    self.chuanyiLab.text = [weatherHandle shareWetherHandle].mod.chuanyi[0];
    self.chuanyiLab.text = [NSString stringWithFormat:@"%@ : %@",@"穿衣", self.chuanyiLab.text];
    [self setMyLab:self.chuanyiLab];

    self.chuanyiLab1.title.text = [weatherHandle shareWetherHandle].mod.chuanyi[1];
    [self setUpLable:self.chuanyiLab1];

    self.xicheLab.text = [weatherHandle shareWetherHandle].mod.xiche[0];
    self.xicheLab.text = [NSString stringWithFormat:@"%@ : %@",@"洗车", self.xicheLab.text];
    [self setMyLab:self.xicheLab];

    self.xicheLab1.title.text = [[weatherHandle shareWetherHandle]mod].xiche[1];
    [self setUpLable:self.xicheLab1];

    self.wuranLab.text = [weatherHandle shareWetherHandle].mod.wuran[0];
    self.wuranLab.text = [NSString stringWithFormat:@"%@ : %@",@"污染", self.wuranLab.text];
    [self setMyLab:self.wuranLab];

    self.wuranLab1.title.text = [[weatherHandle shareWetherHandle] mod].wuran[1];
    [self setUpLable:self.wuranLab1];

    self.ziwaixianLab.text = [weatherHandle shareWetherHandle].mod.ziwaixian[0];
    self.ziwaixianLab.text = [NSString stringWithFormat:@"%@ : %@",@"紫外线",self.ziwaixianLab.text];
    [self setMyLab:self.ziwaixianLab];

    self.ziwaixianLab1.title.text =[weatherHandle shareWetherHandle].mod.ziwaixian[1];
    [self setUpLable:self.ziwaixianLab1];

       NSString *place = [[NSUserDefaults standardUserDefaults] objectForKey:@"city"];
            [self.placeLable setText:place];
           [self.label addSubview:self.placeLable];
    self.pmLab.text = [weatherHandle shareWetherHandle].modlle.pm25;
    self.pmLab.text = [NSString stringWithFormat:@"%@:%@",@"PM25",self.pmLab.text];
    [self weather:self.pmLab];
    self.qualityLab.text = [weatherHandle shareWetherHandle].modlle.quality;
    self.qualityLab.text = [NSString stringWithFormat:@"%@:%@",@"空气质量",self.qualityLab.text];
    [self weather:self.qualityLab];
  

}
- (void)weather:(UILabel *) lab{
    [lab setFont:[UIFont fontWithName:@"HelveticaNeue-UltraLight" size:15]];
    //[lab setBackgroundColor:[UIColor redColor]];
    [lab setTextColor:[UIColor whiteColor]];
    [lab setShadowColor:[UIColor whiteColor]];
    [lab setShadowOffset:CGSizeMake(0.5, 0.5)];
    lab.numberOfLines = 0;
    lab.lineBreakMode = YES;
    [self.label addSubview:lab];
}


- (void)setMyLab:(UILabel *)lab{

    [lab setFont:[UIFont fontWithName:@"HelveticaNeue-UltraLight" size:15]];
    [lab setTextColor:[UIColor whiteColor]];
    [lab setShadowColor:[UIColor whiteColor]];
    [lab setShadowOffset:CGSizeMake(0.5, 0.5)];
    lab.numberOfLines = 0;
    lab.lineBreakMode = YES;

    _attributedString = [[NSAttributedString alloc] initWithString:lab.text];
    lab.attributedText = _attributedString;

    NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:15] forKey:NSFontAttributeName];
    CGSize size = CGSizeMake(9999,2);
    CGSize stingSize = [lab.text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size;
    tempFrame = lab.frame;
    
    tempFrame.size = CGSizeMake(stingSize.width,kWidth/12.5);
    lab.frame = tempFrame;
     [self.towView addSubview:lab];
    
    
}
- (void)setUpLable:(MyScollview *)scoller{
    scoller.showsHorizontalScrollIndicator = NO;
    [scoller.title setFont:[UIFont fontWithName:@"HelveticaNeue-UltraLight" size:15]];
    [scoller.title setTextColor:[UIColor whiteColor]];
    [scoller.title setShadowColor:[UIColor whiteColor]];
    [scoller.title setShadowOffset:CGSizeMake(0.5, 0.5)];
    scoller.title.numberOfLines = 0;
    scoller.title.lineBreakMode = YES;

    [self.towView addSubview:scoller];
    
}


@end
